<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');?>
<div id="closeParentTime" style="display:none"></div>
<script type="text/javascript">
	window.top.$('#display_center_id').css('display','none');
</script>
<div class="pad-10">
<div id="searchid" style="">
<form name="searchform" action="" method="get" >
<input type="hidden" value="<?php echo ROUTE_M?>" name="m">
<input type="hidden" value="<?php echo ROUTE_C?>" name="c">
<input type="hidden" value="<?php echo ROUTE_A?>" name="a">
<input type="hidden" value="1" name="search">
<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">		
				<?php echo L('goods_name')?>：<?php echo form::select($goods, $_GET['source_id'], 'name="source_id"', '请选择')?>
				类型：<?php echo form::select(array('1'=>'少儿投票'), $_GET['type'], 'name="type"', '请选择')?>
				<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
				<a style="float:right;cursor:pointer;" href="javascript:;" onclick="refreshData(15);" class="button">刷新数据</a>
	</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
</div>
<form name="myform" id="myform" action="" method="post" >
<div class="table-list">
    <table width="100%">
        <thead>
            <tr>
			 <th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');" align='center' ></th>
            <th width="30" align='center' >ID</th>
			<th width="100" align='center' ><?php echo L('goods_name');?></th>
			<th width="100" align='center' >类型</th>
			<th width="100" align='center' >商品价格(单位:元)</th>
            <th width="100" align='center' >使用积分</th>
            <th width="100" align='center' >使用金额(单位:元)</th>
            <th width="100" align='center' >个数</th>
            <th width="100" align='center' >添加用户</th>
            <th width="120" align='center' >添加时间</th>
            <th align="center" width="70">上次修改者</th>
			<th width="100" align='center' >状态</th>
            </tr>
        </thead>
<tbody>
    <?php
	if(!empty($lists)) {
		
		foreach ($lists as $r) {
	?>
        <tr>
		<td align="center"><input class="inputcheckbox " name="id[]" value="<?php echo $r['id'];?>" type="checkbox"></td>
		<td align='center' ><?php echo $r['id'];?></td>
		<td align='center'><?=$goods[$r['source_id']]?></td>
		<td align='center'><?php echo $r['type'] == 1?'少儿投票':'<font color="red">（未设置）</font>';?></td>
		<td align='center'><?php echo $r['goods_price']?$r['goods_price']:'<font color="red">（未设置）</font>';?></td>
		<td align='center'><?php echo $r['used_score']?$r['used_score']:'<font color="red">（未设置）</font>';?></td>
		<td align='center'><?php echo $r['used_money']?$r['used_money']:'<font color="red">（未设置）</font>';?></td>
		<td align='center'><?php echo $r['count']?$r['count']:'<font color="red">（未设置）</font>';?></td>
		<td align='center'><?php echo $r['nickname']?$r['nickname']:'<font color="red">（未设置）</font>'?></td>
		<td align='center'><?php echo $r['create_time']?></td>
		<td align='center'><?php echo $r['updated_by']?$adminInfo[$r['updated_by']]:'<font color="red">（未设置）</font>'?></td>
		<td align='center'><a href="javascript:void(0)" data-id="<?=$r['id']?>" data-top="<?=$r['status']?>" onclick="changeTop(this);"><?php echo $r['status'] == 1?'待使用':'已使用';?></a></td>

	</tr>
     <?php }
	} else {
		echo "<tr><td colspan='11' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
	}
	?>
</tbody>
     </table>
    <div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
		<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
		<!-- <input type="button" class="button" value="<?php echo L('delete');?>" onclick="myform.action='?m=reg_child&c=goods&a=del&dosubmit=1&steps=<?php echo $steps;?>';return confirm_delete()"/> -->
	</div>
    <div id="pages"><?php echo $pages;?></div>
</div>
</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript"> 
<!--

function confirm_delete(){
	if(confirm('<?php echo L('confirm', array('message' => L('selected')));?>')) $('#myform').submit();
}

function changeTop(obj){
	var id=$(obj).attr("data-id");
	var status=$(obj).attr("data-top");
	//top为现在状态
	var msg="";
	if(status==1){
		status=2;
		msg='已使用';

	}else{
		status=1;
		msg='待使用';
	}
	$.ajax({
		type:"get",
		url:"?m=reg_child&c=goods&a=goods_status_edit&id="+id+"&status="+status+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
		dataType: "json",
		success:function(data){
			if(data['status']){
				$(obj).text(msg);
				$(obj).attr("data-top",status);
			}else{
				alert(data['msg']);
				return false;
			}
		}
	})
}

setcookie('refersh_time', 0);
function refersh_window() {
	var refersh_time = getcookie('refersh_time');
	if(refersh_time==1) {
		window.location.reload();
	}
}
setInterval("refersh_window()", 3000);
//-->
</script>
</body>
</html>